/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foxmob.mlts.controller.setter;

import foxmob.mlts.model.QuestionPaper;
import foxmob.mlts.model.Section;
import foxmob.mlts.viewcontroller.setter.SetterPreviewForm;
import foxmob.mlts.viewcontroller.student.SectionScrollPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author Lunayo
 */
public class SetterPreviewFormController {
    
    private SetterPreviewForm delegate;
    
    public SetterPreviewFormController(SetterPreviewForm delegate) {
        this.delegate = delegate;
    }
    
    public void loadSection(QuestionPaper testRecord, int sectionLevel) {
        // delete all the tab
        delegate.getPreviewTab().removeAll();
        for (Section section : testRecord.getSections()) {
             JScrollPane jsp = new SectionScrollPanel().loadQuestions(section);     
             delegate.getPreviewTab().addTab(section.getTitle(), jsp);
        }
        delegate.getPreviewTab().setSelectedIndex(sectionLevel);
    }
    
}
